Repository navigation
⚡ Bolt: single-scalar fast path + O(log n) range lookups in world-surface - #10468
Conversation
…face Extend the ASCII-only fast path in renderWorldSurface to every single Unicode scalar value (box-drawing, accented Latin, CJK, emoji, ...) and replace the three linear .some() scans over the wide/text-presentation/ emoji-presentation range tables with binary search over flattened Int32Arrays. A single scalar is always exactly one grapheme cluster (verified exhaustively over U+0000..U+10FFFF against Intl.Segmenter), so it skips Intl.Segmenter (~3 us/cell) and the per-cell Array.from/map/reduce allocations. U+200D stays on the general path because its graphemeWidth shortcut diverges from codePointWidth. Measured in Bun/JSC with document.createElement stubbed (per .jules/bolt.md guidance), a full 120x50 frame: box-drawing: 51.9 ms -> 2.1 ms (~25x) emoji: 27.3 ms -> 1.2 ms (~23x) latin1: 20.5 ms -> 0.8 ms All 828 web tests pass; typecheck clean.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
# Conflicts: # .jules/bolt.md # pkgs/id/web/src/world-surface.ts
💡 What
renderWorldSurfaceinpkgs/id/web/src/world-surface.tsis the hot path for every world screen frame (up to 6000 cells). Two changes:U+0020..U+007E). Every other single Unicode scalar value (box-drawing borders, accented Latin, CJK, emoji, Greek, Cyrillic, …) still paidIntl.Segmenter.segment()(~3 µs/cell) plus per-cellArray.from/map/reduceallocations. A single scalar value is always exactly one grapheme cluster (verified exhaustively overU+0000..U+10FFFFagainstIntl.Segmenter), so all of them now skip segmentation and compute their width directly viacodePointWidth.U+200Dis deliberately kept on the general path because itsgraphemeWidthshortcut diverges fromcodePointWidth.isWideCodePoint,isTextPresentationCodePointandisEmojiPresentationSeqBasescanned their 80–180 entry tables linearly with.some(), once per non-ASCII cell. The tables are now flattened intoInt32Arrays and queried with binary search (all three tables verified sorted and disjoint).🎯 Why
A 120×50 frame of box-drawing glyphs took ~52 ms of CPU (≈8.6 µs/cell) instead of ~2 ms, because each cell paid the full linear scan and a full
Intl.Segmentersegmentation. That breaks the 20 fps (50 ms/frame) budget for any non-ASCII world.📊 Impact
Measured in Bun/JSC with
document.createElementstubbed (per.jules/bolt.md, happy-dom element creation dominates and hides the renderer's own CPU), full 6000-cell frame:─)😀)é)The DOM/element-creation cost is unchanged.
🔬 Measurement
bun run typecheck(tsc) — clean.bun run test(vitest) — 828 tests pass, 9 skipped.U+0000..U+10FFFF: single-scalar fast-path width matches the general path for every scalar except the excludedU+200D; binary-search predicate results match the linear scans for every code point.screen-cell-parity.jsonRust/TS corpus continues to pass on both sides.🔗 References
.jules/bolt.mdentry "Per-cell Intl.Segmenter validation dominates the world screen renderer" (2026-11-04).Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.